
--by Chris Mackey

--pieces
--body
local head = piece "head"
local neck = piece "neck"
local torso = piece "torso"
local pelvis = piece "pelvis"
local kilt = piece "kilt"


--left side
local l_arm = piece "l_arm"
local l_fore = piece "l_fore"
local l_hand = piece "l_hand"
local l_thigh = piece "l_thigh"
local l_shin = piece "l_shin"
local l_foot = piece "l_foot"

--right side
local r_arm = piece "r_arm"
local r_fore = piece "r_fore"
local r_hand = piece "r_hand"
local r_thigh = piece "r_thigh"
local r_shin = piece "r_shin"
local r_foot = piece "r_foot"


function Walk()
	SetSignalMask( 2 )
	while( true ) do 
		Turn( torso, y_axis, .25, 1 )
		Turn( head, y_axis, -.25, 1 )
		Turn( kilt, y_axis, -.5, 2.8 )
		Move( pelvis, y_axis, 2, 7 )
		
		Turn( l_arm, x_axis, .4, 2 )
		Turn( l_fore, x_axis, -.5, 2 )
		Turn( l_thigh, x_axis, -.5, 3 ) -- forward
		Turn( l_shin, x_axis, .5, 1.7 )
		
		Turn( r_arm, x_axis, -.5, 3 )
		Turn( r_fore, x_axis, -.3, 3 )
		Turn( r_thigh, x_axis, .5, 2 )
		Turn( r_shin, x_axis, 0, 2 )
		
		WaitForMove( pelvis, y_axis )
		Move( pelvis, y_axis, 0, 8 )
		Sleep( 250 )
		
		Turn( torso, y_axis, -.25, 1 )
		Turn( head, y_axis, .25, 1 )
		Turn( kilt, y_axis, .5, 2.8 )
		Move( pelvis, y_axis, 2, 7 )
		
		Turn( l_arm, x_axis, -.5, 3 )
		Turn( l_fore, x_axis, -.3, 3 )
		Turn( l_thigh, x_axis, .5, 2 ) -- backwards
		Turn( l_shin, x_axis, 0, 2 )
		
		Turn( r_arm, x_axis, .4, 2 )
		Turn( r_fore, x_axis, -.5, 2 )
		Turn( r_thigh, x_axis, -.5, 3 )
		Turn( r_shin, x_axis, .5, 1.7 )
		
		WaitForMove( pelvis, y_axis )
		Move( pelvis, y_axis, 0, 8 )
		Sleep( 250 )
	end
end


function StopWalk()
	Move( pelvis, x_axis, 0, 10 )
	Move( pelvis, y_axis, 0, 10 )
	Move( pelvis, z_axis, 0, 10 )
	
	Turn( head, y_axis, 0, 2 )
	Turn( head, x_axis, 0, 2 )
	Turn( head, z_axis, 0, 2 )
	Turn( torso, x_axis, 0, 2 )
	Turn( torso, y_axis, 0, 2 )
	Turn( torso, z_axis, 0, 2 )
	Turn( kilt, x_axis, 0, 2 )
	Turn( kilt, y_axis, 0, 2 )
	Turn( kilt, z_axis, 0, 2 )
	
	Turn( l_arm, x_axis, 0, 2 )
	Turn( l_arm, y_axis, 0, 2 )
	Turn( l_arm, z_axis, 0, 2 )
	Turn( l_fore, x_axis, 0, 2 )
	Turn( l_fore, y_axis, 0, 2 )
	Turn( l_fore, z_axis, 0, 2 )
	Turn( l_hand, x_axis, 0, 2 )
	Turn( l_hand, y_axis, 0, 2 )
	Turn( l_hand, z_axis, 0, 2 )
	
	Turn( r_arm, x_axis, 0, 2 )
	Turn( r_arm, y_axis, 0, 2 )
	Turn( r_arm, z_axis, 0, 2 )
	Turn( r_fore, x_axis, 0, 2 )
	Turn( r_fore, y_axis, 0, 2 )
	Turn( r_fore, z_axis, 0, 2 )
	Turn( r_hand, x_axis, 0, 2 )
	Turn( r_hand, y_axis, 0, 2 )
	Turn( r_hand, z_axis, 0, 2 )
	
	Turn( l_thigh, 1, 0, 3 )
	Turn( l_thigh, 2, 0, 1 )
	Turn( l_thigh, 3, 0, 1 )
	Turn( l_shin, 1, 0, 3 )
	Turn( l_shin, 2, 0, 3 )
	Turn( l_shin, 3, 0, 3 )
	Turn( l_foot, 1, 0, 4 )
	Turn( l_foot, 2, 0, 4 )
	Turn( l_foot, 3, 0, 1 )
	
	Turn( r_thigh, 1, 0, 3 )
	Turn( r_thigh, 2, 0, 1 )
	Turn( r_thigh, 3, 0, 1 )
	Turn( r_shin, 1, 0, 3 )
	Turn( r_shin, 2, 0, 3 )
	Turn( r_shin, 3, 0, 3 )
	Turn( r_foot, 1, 0, 4 )
	Turn( r_foot, 2, 0, 4 )
	Turn( r_foot, 3, 0, 1 )
end
